import multiprocessing
import time
import threading
import functools

import utils.myconfig as config

# 操作间隔时间（秒）
interval = float(config.get_config("TIMMER", "operation_interval"))
# 总执行时长（秒）
total_seconds = int(config.get_config("TIMMER", "total_minutes"))

def run_every_second(func):
    def wrapper(*args, **kwargs):
        start_time = time.time()
        count = 0
        while True:
            current_time = time.time()
            if current_time - start_time >= total_seconds:
                break
            func(*args, **kwargs)
            time.sleep(interval)
            count += 1
        print(f"函数总共执行了{count}次")

    return wrapper